Additional Question 1 Implementation

My first additional question is basically my base question but with my disrupting galaxy's mass being a third of the main galaxy's.


In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint

In [2]:
from initial_velocities import velocities_m, velocities_S
from DE_solver import derivs, equationsolver

Defining empty initial condition array:


In [3]:
ic_add1 = np.zeros(484)

Setting values for S,M, and t:


In [4]:
max_time_add1 = 1.5
time_step_add1 = 120
M_add1 = 1e11
S_add1 = M_add1/3

In [5]:
S_y_add1 = 70
S_x_add1 = -.01*S_y_add1**2+25
vxS_add1 = velocities_S(M_add1,S_add1,S_x_add1,S_y_add1)[0]
vyS_add1 = velocities_S(M_add1,S_add1,S_x_add1,S_y_add1)[1]

Setting initial condition array values pertaining to S:


In [6]:
ic_add1[0] = S_x_add1
ic_add1[1] = S_y_add1
ic_add1[2] = vxS_add1
ic_add1[3] = vyS_add1

Loading the positions of my stars:


In [7]:
f = open('star_positions.npz','r')
r = np.load('star_positions.npz')
x_y = r['arr_0']
f.close()

Putting these values into my initial condition array, as well calling the initial velocity function on each position:


In [8]:
for i in range(0,120):
    ic_add1[(i+1)*4] = x_y[0][i]
    ic_add1[((i+1)*4)+1] = x_y[1][i]

In [9]:
for n in range(1,int(len(ic_add1)/4)):
    ic_add1[n*4+2] = velocities_m(M_add1,ic_add1[n*4],ic_add1[n*4+1])[0]
    ic_add1[n*4+3] = velocities_m(M_add1,ic_add1[n*4],ic_add1[n*4+1])[1]

Calling my differential equation solver, and saving the data to disk:

Took 1 min and 7 sec last I timed it


In [57]:
sol_add1 = equationsolver(ic_add1,max_time_add1,time_step_add1,M_add1,S_add1)

In [58]:
np.savez('additional_1_data.npz',sol_add1,ic_add1)

In [ ]: